//找到li ul
let li = document.querySelectorAll('.txt-wrap>li')
let ul = document.querySelector('.txt-wrap')
let id
let index = 0
//鼠标移入时执行的操作
ul.addEventListener('mouseenter', stop, false);
//鼠标移出时触发的函数和操作
ul.addEventListener('mouseleave', loop, false);


//换值
function getTxt() {
    ul.innerHTML = li[index].innerHTML
    index++
    console.log(index);
    if (index > li.length - 1) {
        index = 0
    }
}

function loop() {
    id = setInterval(function () {
        getTxt()
    }, 1000)
}
loop()


function stop() {
    if (id) {
        clearInterval(id)
    }

}